<?php if ($this->mode == INSERT_MODE): ?>
    <?php $title = 'New Main Port' ?>
<?php else: ?>
    <?php $action = $this->url(array('action' => 'editport')); ?>
    <?php $title = 'Edit Main Port' ?>
<?php endif; ?>

<h1>
    <?php echo $title ?>
</h1>

<form method='POST' enctype="multipart/form-data">
    <div class='wrap-content'>
        <label>
            Port Name
        </label>   
        <div class='content'>                 
            <div class='wrap-input'>
                <input type='text' name='name' value='<?php echo isset($this->main_port) ? $this->main_port->name : '' ?>'/>
            </div>
        </div>
    </div>
    <div class='wrap-content'>
        <label>
            Region
        </label>   
        <div class='content'>                 
            <div class='wrap-input'>
                <select name="region">
                    <?php foreach ($this->regions as $region): ?>
                        <option value="<?php echo $region ?>" <?php echo isset($this->main_port) && $this->main_port->region == $region ? 'selected' : '' ?>><?php echo $region ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
        </div>
    </div>  
    <div class='wrap-content'>
        <label>
            PDF File
        </label>   
        <div class='content'>                 
            <div class='wrap-input'>
                <input type="file"  name='file' id='file'/>
            </div>
            <?php if ($this->main_port): ?>
                <div style="padding: 10px 0px">
                    <a href="<?php echo UPLOAD_URL . $this->main_port->file ?>" target="_blank">
                        <?php echo $this->main_port->file ?>
                    </a>
                </div>
            <?php endif; ?>
            <input type="submit"  name='submit' class="submit-button"/>
        </div>
    </div>          
</form>